﻿using System;
using System.Windows.Forms;

namespace 售后客户管理
{
    public partial class ComboboxSingleSelection : UserControl
    {
        public ComboboxSingleSelection()
        {
            InitializeComponent();
            this.SizeChanged += ComboboxSingleSelection_SizeChanged;
            this.FontChanged += ComboboxSingleSelection_FontChanged;
            this.TextChanged += ComboboxSingleSelection_TextChanged;
        }

        private void ComboboxSingleSelection_TextChanged(object sender, System.EventArgs e)
        {
            this.comboBox1.Text = this.Text;
        }

        private void ComboboxSingleSelection_FontChanged(object sender, System.EventArgs e)
        {
            this.Width = this.label1.Width + this.comboBox1.Width + Convert.ToInt32(this.Font.Size) + 6;
            this.Height = this.comboBox1.Height + 6;
        }

        private void ComboboxSingleSelection_SizeChanged(object sender, System.EventArgs e)
        {
            this.comboBox1.Width = this.Width - this.label1.Width - Convert.ToInt32(this.Font.Size) - 6;
        }

        public string NameText
        {
            get { return this.label1.Text; }
            set { this.label1.Text = value; }
        }
        public object DataSource
        {
            get { return this.comboBox1.DataSource; }
            set { comboBox1.DataSource = value; }
        }
        public string DisplayMember
        {
            get => this.comboBox1.DisplayMember;
            set => this.comboBox1.DisplayMember = value;
        }
        public string ValueMember
        {
            get => this.comboBox1.ValueMember;
            set => this.comboBox1.ValueMember = value;
        }
        public override string Text
        {
            get => this.comboBox1.Text;
            set => this.comboBox1.Text = value;
        }
    }
}
